package com.zpark;

import javax.jws.WebParam;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

@WebServlet(
		name = "ServletConfig02",
		value = "/sc02.do",
		initParams = {
				@WebInitParam(name = "uname", value = "大锤"),
				@WebInitParam(name = "pwd", value = "888888")
		}
)
public class ServletConfig02 extends HttpServlet {

	private ServletConfig config;

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		Enumeration<String> names = this.config.getInitParameterNames();
		while (names.hasMoreElements()) {
			String name = names.nextElement();
			System.out.println(name + ":" + this.config.getInitParameter(name));
		}
	}

	@Override
	public void init(ServletConfig config) throws ServletException {
		this.config = config;
	}
}
